home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / GDIBASE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  101 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Definition of base most abstract GDI object class, and associated exception
  8. // class
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_GDIBASE_H)
  11. #define OWL_GDIBASE_H
  12.  
  13. #if !defined(OWL_DEFS_H)
  14. # include <owl/defs.h>
  15. #endif
  16. #if !defined(WINSYS_COLOR_H)
  17. # include <winsys/color.h>
  18. #endif
  19. #if !defined(OWL_EXCEPT_H)
  20. # include <owl/except.h>
  21. #endif
  22. #if !defined(CLASSLIB_POINTER_H)
  23. # include <classlib/pointer.h>   // get this header for backward compatibility
  24. #endif
  25.  
  26. #if defined(BI_NAMESPACE)
  27. namespace OWL {
  28. #endif
  29.  
  30. // Generic definitions/compiler options (eg. alignment) preceeding the 
  31. // definition of classes
  32. #include <services/preclass.h>
  33.  
  34. //
  35. // class TXGdi
  36. // ~~~~~ ~~~~~
  37. // Base GDI exception class. Handles all GDI related exceptions
  38. //
  39. class _OWLCLASS_RTL TXGdi : public TXOwl {
  40.   public:
  41.     TXGdi(uint resId = IDS_GDIFAILURE, HANDLE handle = 0);
  42.  
  43.     static string Msg(uint resId, HANDLE);
  44.  
  45. #if defined(BI_NO_COVAR_RET)
  46.     TXBase* Clone();
  47. #else
  48.     TXGdi* Clone();
  49. #endif
  50.     void Throw();
  51.  
  52.     static void Raise(uint resId = IDS_GDIFAILURE, HANDLE handle = 0);
  53. };
  54.  
  55. //
  56. // Flag for Handle ctors to control Handle deletion in dtor
  57. //
  58. enum TAutoDelete { NoAutoDelete, AutoDelete };
  59.  
  60. //
  61. // class TGdiBase
  62. // ~~~~~ ~~~~~~~~
  63. // Root and abstract class for Windows object wrappers. Provides basic
  64. // notion of working with a handle, and constructing a C++ object with
  65. // an aliased handle.
  66. //
  67. class _OWLCLASS TGdiBase {
  68.   protected:
  69.     HANDLE      Handle;       // GDI handle of this object
  70.     bool        ShouldDelete; // Should object delete GDI handle in dtor?
  71.  
  72.     // Throws exception if object is bad
  73.     //
  74.     void        CheckValid(uint resId = IDS_GDIFAILURE);
  75.     static void CheckValid(HANDLE handle, uint resId = IDS_GDIFAILURE);
  76.  
  77.     // Constructors for use by derived classes only
  78.     //
  79.     TGdiBase();
  80.     TGdiBase(HANDLE handle, TAutoDelete autoDelete = NoAutoDelete);
  81.  
  82.   private:
  83.     TGdiBase(const TGdiBase&); // Protect against copying & assignment
  84.     TGdiBase& operator =(const TGdiBase&);
  85.  
  86. #if defined(OWL2_COMPAT)
  87.   public:
  88.     typedef ::TXGdi TXGdi;  // Exceptions moved to global scope
  89. #endif
  90. };
  91.  
  92. // Generic definitions/compiler options (eg. alignment) following the 
  93. // definition of classes
  94. #include <services/posclass.h>
  95.  
  96. #if defined(BI_NAMESPACE)
  97. } // namespace OWL
  98. #endif
  99.  
  100. #endif  // OWL_GDIBASE_H
  101.